import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)


const routes = [
  {
    path: '/',
    redirect: '/index' // 重定向
  },
  {
    path: '/index',
    component: () => import("../views/index.vue"),
    meta: {
      title: '挺想租',
      isKeep: true   //被缓存的路由
    }
  },
  {
    path: '/goodsDetail',
    component: () => import("../views/goodsDetail.vue"),
    meta: {
      title: '详情'
    }
  },
  {
    path: '/more',
    component: () => import("../views/more.vue"),
    meta: {
      title: '更多'
    }
  },
  {
    path: '/search',
    component: () => import("../views/search.vue"),
    meta: {
      title: '搜索'
    }
  },
  {
    path: '/my',
    component: () => import("../views/personal.vue"),
    meta: {
      title: '个人中心'
    }
  },
  {
    path: '/help',
    component: () => import("../views/help.vue"),
    meta: {
      title: '帮助中心'
    }
  },
  {
    path: '/complain',
    component: () => import("../views/complain.vue"),
    meta: {
      title: '投诉与建议'
    }
  }
]

const router = new Router({
  routes
})

router.beforeEach((to, from, next) => {
  document.title = to.matched[0].meta.title
  next()
})

export default router